<?php

declare(strict_types=1);

namespace Modules\Inspection\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class Inspection extends Model
{
    

    protected $table = 'inspection';

    protected $casts = [ 
        'productname' => 'array', 
    ]; 

    protected $fillable = [ 'id', 'inspectionnumber','productname','creator_id', 'created_at', 'updated_at', 'deleted_at','completecheck' ];

    /**
     * @var array
     */
    protected array $fields = ['id','created_at','updated_at', 'inspectionnumber','productname','completecheck'];

    /**
     * @var array
     */
    protected array $form = ['id','created_at','updated_at', 'inspectionnumber','productname','completecheck'];

    /**
     * @var array
     */
    public array $searchable = [
        'inspectionnumber' => 'like',
        'productname' => 'like',
    ];

     //输出相应的时间格式
     protected function serializeDate($date)
     {
     return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
     }

    /**
     * 链表查询
     */
     public function detailscheckOne()
    {
        return $this->hasOne(Inspectioncheck::class);//查一条
    }

    public function detailscheckAll()
    {
        return $this->hasMany(Inspectioncheck::class);//查多条
    }
    
}
